package cn.yi.fast.security.domain;

import cn.yi.fast.security.validation.AddGroup;
import cn.yi.fast.security.validation.UpdateGroup;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;

@Data
public class User implements Serializable {
    private Long userId;
    @NotBlank(message="用户名不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String username;

    /**
     * 密码
     */
    @NotBlank(message="密码不能为空", groups = AddGroup.class)
    @JSONField(serialize=false)
    private String password;

    private Integer status;

    private Integer isAdmin;

    //保存时设置值，每个用户都是独立的 String salt = RandomStringUtils.randomAlphanumeric(20);
    //保存密码时，使用唯一标记进行加密 ShiroUtils.sha256(user.getPassword(), user.getSalt())
    private String salt;
}
